#include "stdafx.h"
#include "statusbar.h"

class StatusBarPrivate
{
public:
	StatusBarPrivate(StatusBar* parent)
		: progress(new QProgressBar(parent))
		, pixelPos(new QLabel(parent))
		, machinePos(new QLabel(parent))
	{
		progress->setTextVisible(false);
		progress->setFixedHeight(18);
	}
public:
	QProgressBar* progress;
	QLabel* pixelPos;
	QLabel* machinePos;
};

StatusBar::StatusBar(QWidget *parent)
	: QStatusBar(parent)
	, d_ptr(new StatusBarPrivate(this))
{
	Q_D(StatusBar);
	addPermanentWidget(d->progress);
	d->pixelPos->setText(tr("Pixel (X:0,Y:0)"));
	addPermanentWidget(d->pixelPos);
	d->machinePos->setText(tr("MM (X:0,Y:0)"));
	addPermanentWidget(d->machinePos);	
}

StatusBar::~StatusBar()
{

}

void 
StatusBar::updateProgress(const int value)
{
	Q_D(StatusBar);
	d->progress->setValue(value);
}

void 
StatusBar::updatePixelPos(const QPoint& point)
{
	Q_D(StatusBar);
	QString text = QString(tr("Pixel (X:%1,Y:%2)")).arg(point.x()).arg(point.y());
	d->pixelPos->setText(text);
}

void 
StatusBar::updateMachinePos(const QPointF& point)
{
	Q_D(StatusBar);
	QString text = QString(tr("Pixel (X:%1,Y:%2)")).arg(point.x()).arg(point.y());
	d->pixelPos->setText(text);
}